package com.miyu.system.utils.enumeration;

import com.alibaba.fastjson2.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

/**
 * 结果枚举
 * @author miyu
 */
@Getter
@ToString
@AllArgsConstructor
public enum ResultEnum {
    /** 成功 */
    SUCCESS("101", "操作成功",DialogStatus.SUCCESS.getStatus()),
    /** 信息 */
    INFO("102", "消息提示",DialogStatus.INFO.getStatus()),
    /** 警告 */
    WARNING("103", "消息警告",DialogStatus.WARNING.getStatus()),
    /** 错误 */
    ERROR("104", "操作失败",DialogStatus.ERROR.getStatus()),;


    private final  String code;
    private final String msg;
    private final Integer status;
    public static JSONObject getInfoByCode(String code) {
        JSONObject result = new JSONObject();
        for (ResultEnum s : values()) {
            if (s.getCode().equals(code)) {
                result.put("code",s.getCode());
                result.put("msg",s.getMsg());
                result.put("status",s.getStatus());
                break;
            }
        }
        return result;
    }



}
